<template>
 <div class="creditList" >
   <div class="creditList_item" v-for="(item,index) of creditList" :key="index">
      <div class="left_side">
        <div class="creditList_item_title">
          <span :class="{dot:true,dot_add:item.integral>0}"></span>
          <span>{{item.goods_name}}</span>
        </div>
        <div class="creditList_item_desc" v-if="item.goods_info">
          {{item.goods_info.info}}
        </div>
        <div class="creditList_item_time">
          {{item.created_at}}
        </div>
      </div>
      <div :class="{right_side:true,credit_add:item.integral>0}">
        <span v-show="item.integral>0">+</span>{{item.integral}}
      </div>
   </div>
   <noContent v-if="creditList.length==0"></noContent>
 </div>
</template>

<script>

import noContent from '@/components/noContent';
export default {
  data() {
    return {
      creditList:''
    }
  },
  methods: {
    async getCreditList(){
      let userToken=wx.getStorageSync('userToken')
      let res=await this.$request.getData('/ucenter/getUserIntegralList',{user_token:userToken})
      if(res.data.level=='success'){
        this.creditList=res.data.data
      }
    }
  },
  components:{
    noContent
  },
  mounted() {
    this.getCreditList()
  },
}
</script>

<style lang="scss">
  .creditList{
    width:100%;
    min-height: 100%;
    background: #eee;
    padding-top:5px;
    &_item{
      margin:10px 0;
      background: #fff;
      width:100%;
      height:120px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      border-bottom:1px solid #eee;
      &>.left_side{
        margin-left:10px;
        height: 100%;
        width:75%;
        display: flex;
        flex-wrap: wrap;
        align-content: space-around;
      }
      &>.right_side{
        margin-right:10px;
        color:orange;
        font-size: 20px;
      }
      .creditList_item_title{
        font-size: 14px;
        display: flex;
        align-items: center;
      }
      .creditList_item_desc,.creditList_item_time{
        font-size: 12px;
        color:gray;
        overflow:hidden; 
        text-overflow:ellipsis;
        display:-webkit-box; 
        -webkit-box-orient:vertical;
        -webkit-line-clamp:2; 
        width:75%;
      }
    }
  }
  .dot{
    width:10px;
    height: 10px;
    border-radius: 50%;
    background: orange;
    margin-right:5px;
  }
  .dot_add{
    background: green
  }
  .credit_add{
    color:green !important;
  }

</style>
